<?php

Class indexController Extends baseController {

	public function index() { 
		$tivi = new tivi(); //echo '<pre>'; var_dump($hangsanxuat->getAllHangSanXuat()); die();
		$hangsanxuat = new hangsanxuat();
		$current_page = (isset($_REQUEST['page'])) ? $_REQUEST['page'] : 1;
		$pos = ($current_page -1 ) * __PAGE_SIZE;
		$lstTv = $tivi->getTiviByWherePaging('t.TrangThai = 1 and t.SoLuong > 0','',$pos);
		//foreach($lstTv as $item){
//			$hangsx = $hangsanxuat->getHangSanXuatById($item->idHangSanXuat);
//			$item->idHangSanXuat = $hangsx->TenHang;
//		}
		$count = count((array)$tivi->getTiviByWhere('t.TrangThai = 1 and t.SoLuong > 0',''));
		$pages = ceil($count/__PAGE_SIZE);

		$this->registry->template->lstTivi = $lstTv;
		$this->registry->template->pages = $pages;
		$this->registry->template->show('index');
	}
	
	public function support(){
		$supportModel = new support();
		$lstSupport = $supportModel->getSupportByWhere('TrangThai=1','');
		$this->registry->template->lstSupport = $lstSupport ;
		$this->registry->template->show('support');
	}

}

?>
